<include file=".:Common:header" />
<script language="javascript">
$(function(){
	$('#datagrid').treegrid({
		title:'{$page_title}',
		width:'100%',
		rownumbers: true,
		animate:true,
		collapsible:true,
		url:'{:U("system/Sets/baseset_list")}&d='+Math.random(),
		idField:'id',
		treeField:'name',
		frozenColumns:[[
			{field:'id',title:'ID',width:30},
			{title:'分类名称',field:'name',width:150}
		]],
		columns:[[
			{field:'value',title:'值',width:80},
			{field:'sort',title:'排序',width:80},
			{field:'remark',title:'备注',width:100},
			{field:'opt',title:'操作',width:180, formatter:function(v, r){
				return '<div class="opt"><a href="javascript:;" onclick="toEdit('+r.id+')" class="edit">编辑</a><a href="javascript:;" onclick="doDelete('+r.id+')" class="delete">删除</a></div>';}}
		]]
	});
});
function query(){
	  $('#datagrid').datagrid('options').queryParams={
	  data:{
	  name:$('#query').find('#name').val(),
	  service_id:$('#query').find('#service_id').val(),
	  type:$('#query').find('#type').val(),
	  info:$('#query').find('#info').val()
	    }
	  }
	  $('#datagrid').datagrid('reload');
	 $('#query').window('close');

}
/*修改*/
function toEdit(id){
	window.location.href='{:U("Sets/baseset_edit")}&id='+id;
}
/*删除*/
function doDelete(id){
	$.messager.confirm('提示', '确定删除该属性组吗？', function(r){
		if (r){
			$.ajax({
				url : '{:U("system/Sets/deleteCategory")}',
				data : 'id='+id,
				dataType: 'json',
				success : function(d){
					if(d.status == 0){
						alertText(d.info, 'error');
					}else{
						$('#datagrid').treegrid('reload');
					}
				}
			});
		}
	});
}
</script>
<div class="wrapper clear">
	<div class="main">
		<if condition="!empty($button)">
        <div class="toolbar">
			<a href="{:U('system/Sets/baseset_add')}" id="addnewitem">新增数据</a>
			<a href="{:U('system/Sets/index')}" id="setting">系统设置</a>
		</div>
		</if>
		<div class="search">
            <div class="searchbox">
<table id="datagrid"></table>
			</div>
		</div>		
	</div>
</div>	
<include file=".:Common:footer" />